import request from '@/utils/request'

export const gettodoList = (data) => {
  return request({
    url: '/flowable/task/todolist',
    method: 'post',
    data: {
      page: data.page,
      pageSize: data.pageSize,
    }
  })
}

export const completeTask = (data) => {
  return request({
    url: '/flowable/task/complete',
    method: 'post',
    data: {
      taskId: data.taskId,
      // variables: data.variables,
      instanceId: data.instanceId,
      comment: data.comment
    }
  })
}

export const rejectTask = (data) => {
  return request({
    url: '/flowable/task/reject',
    method: 'post',
    data: {
      taskId: data.taskId,
      instanceId: data.instanceId,
      comment: data.comment
    }
  })
}

export const getrecords = (procInsId) => {
  return request({
    url: '/flowable/task/records/' + `${procInsId}`,
    method: 'get',
  })
}

export const getFinishedList = (data) => {
  return request({
    url: '/flowable/task/finishedlist',
    method: 'post',
    data: data
  })
}

export const revokeTask = ({ procInsId }) => {
  return request({
    url: '/flowable/task/revoke',
    method: 'put',
    data: {
      instanceId: procInsId
    }
  })
}

export const getMyProcess = (data) => {
  return request({
    url: '/flowable/task/myprocess',
    method: 'post',
    data: data
  })
}

export const stopProcIns = (procInsId) => {
  return request({
    url: '/flowable/task/stop/' + `${procInsId}`,
    method: 'put',
  })
}

export const removeProcIns = (procInsId) => {
  return request({
    url: '/flowable/task/remove/' + `${procInsId}`,
    method: 'put',
  })
}

export const getCandidateTask = (data) => {
  return request({
    url: '/flowable/task/candidate',
    method: 'post',
    data: {
      page: data.page,
      pageSize: data.pageSize,
    }
  })
}

export const claimCandidateTask = (taskId) => {
  return request({
    url: '/flowable/task/claim/' + `${taskId}`,
    method: 'put',
  })
}
export const unclaimCandidateTask = (taskId) => {
  return request({
    url: '/flowable/task/unclaim/' + `${taskId}`,
    method: 'put',
  })
}